;;;Select everything that is NOT layer and color BYBLOCK.
;;;
;;;	Author:
;;;		Henry C. Francis
;;;		425 N. Ashe St.
;;;		Southern Pines, NC 28387
;;;
;;;	http://www.paracadd.com
;;;	All rights reserved.
;;;
(defun c:notby ()
  (setq notss (ssget "x" '((-4 . "<not")
                             (-4 . "<and")
                               (6 . "BYBLOCK")
                               (62 . 0)
                             (-4 . "and>")
                           (-4 . "not>")
                          )
              )
  )
  (setq ssndx 0
        sslen (sslength notss)
        entlst nil
  )
  (while (/= ssndx sslen)
    (if (or
          (and
            (assoc 6 (entget(ssname notss ssndx)))
            (/=(cdr(assoc 6(entget(ssname notss ssndx))))"BYBLOCK")
          )
          (and
            (assoc 62 (entget(ssname notss ssndx)))
            (/=(cdr(assoc 62 (entget(ssname notss ssndx))))0)
          )
        )
        (if entlst
          (setq entlst (append entlst (list (ssname notss ssndx))))
          (setq entlst (list (ssname notss ssndx)))
        )
    )
    (setq ssndx (1+ ssndx))
  )
  (setq notss nil)
  (if entlst
    (progn
      (setq notss (ssadd (car entlst)))
      (foreach n (cdr entlst)
        (ssadd n notss)
      )
    )
  )
  (command ".select" notss)
  (princ)
)